package com.etc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.etc.util.PageData;
import org.springframework.stereotype.Service;

import com.etc.dao.TravelsMapper;
import com.etc.entity.Travels;
import com.etc.service.TravelsService;

@Service
public class TravelsServiceImpl implements TravelsService {

    @Resource
    private TravelsMapper tm;

    @Override
    public boolean deleteByPrimaryKey(Integer traId) {
        // TODO Auto-generated method stub
        return tm.deleteByPrimaryKey(traId) > 0;
    }

    @Override
    public boolean insert(Travels record) {
        // TODO Auto-generated method stub
        return tm.insert(record) > 0;
    }

    @Override
    public boolean insertSelective(Travels record) {
        // TODO Auto-generated method stub
        return tm.insertSelective(record) > 0;
    }

    @Override
    public Travels selectByPrimaryKey(Integer traId) {
        // TODO Auto-generated method stub
        return tm.selectByPrimaryKey(traId);
    }

    @Override
    public boolean updateByPrimaryKeySelective(Travels record) {
        // TODO Auto-generated method stub
        return tm.updateByPrimaryKeySelective(record) > 0;
    }

    @Override
    public boolean updateByPrimaryKey(Travels record) {
        // TODO Auto-generated method stub
        return tm.updateByPrimaryKey(record) > 0;
    }

    @Override
    public List<Travels> selectAll() {
        // TODO Auto-generated method stub
        return tm.selectAll();
    }

    @Override
    public List<Travels> selectByUserid(int userId) {
        // TODO Auto-generated method stub
        return tm.selectByUserid(userId);
    }

    @Override
    public PageData<Travels> selecTravelsByPage(Integer page, Integer limit, String content) {
        //得到起始位置
        int start = (page - 1) * limit;
        //得到记录总数
        int count = tm.countTravelsByPage(content);
        List<Travels> travels = tm.selecTravelsByPage(start, limit, content);
        PageData<Travels> pageData=new PageData<>(travels, count, limit, page);
        pageData.setCode(0);
        pageData.setMsg("操作成功");
        return pageData;
    }
}
